#ifndef FindDialog_First
#define FindDialog_First
#ifdef __GNUG__
#pragma interface
#endif

#include "Dialog.h"

class RegularExp;
class TextView;
class TextField;
class OneOfCluster;
class ManyOfCluster;
class VObject;

//---- id's --------------------------------------------------------------------

const int cIdFind             = cIdFirstUser + 1,
		cIdDoFind           = cIdFirstUser + 2,
		cIdFindOpt          = cIdFirstUser + 3,
				cIdIgnCase    = cIdFindOpt,
				cIdMatchWord  = cIdFindOpt   + 1,
		cIdFindMode         = cIdFirstUser + 13,
				cIdForward    = cIdFindMode,
				cIdBackward   = cIdFindMode  + 1;

//---- FindDialog --------------------------------------------------------------

class FindDialog : public Dialog {
public:
	MetaDef(FindDialog);
	FindDialog(const char *title);
	~FindDialog();
	void SetTextViewFocus(TextView *tvp);
	TextView *GetTextViewFocus();
	void FindAgain();
	const char *GetSearchPattern();
	virtual bool DoFind(const char *str, bool forward, bool msg= TRUE);

protected:
	VObject *DoMakeControls();
	VObject *DoMakeActions();
	void DoSetup();
	void DoSetDefaults();
	void Control(int id, int, void *v);
	void SendDown(int id, int, void *v);
	bool Compile(const char *pattern);

protected:
	RegularExp *rex;
	TextView *tvp;
	TextField *ei1;
	OneOfCluster *modecl;
	ManyOfCluster *optionscl;
	VObject *find;
	bool atEnd, atBegin;
};

#endif
